{* $Id$ *}
{include_core file="admin/lib/header.html" title="影院周简报"}
<div class="page-header border-bottom clearfix">
    <h2 class="left">影院周简报</h2>
    <a href="{AnUrl("cinema/admin/cinema_daily_brief?{URLTracker::set("is_excel", 1)}")}" target="_blank" style="margin-top:5px; display:block; float:right;" class="btn btn-xs btn-primary js_downList">导出EXCEL</a>
</div>

<div class="search-form js_advancedForm">
    <form action="cinema/admin/cinema_daily_brief" method="get" class="js_focusSearchForm">
        <p>
            <label for="" class="search-f-label">影院名称：</label>
            <input type="text" class="search-f-ipt1" name="search_filter[title]" value="{$search_filter.title}">
        </p>
        <p style="height: auto;">
            <label class="search-f-label">选择省份：</label>
            {foreach $provinceList as $k => $v}
            <label class="label label-default"><input value="{$k}" name="search_filter[province_id][]" {if isset($search_filter['province_id']) && in_array($k, $search_filter['province_id'])}checked="checked"{/if} type="checkbox">{$v}</label>&nbsp;&nbsp;
            {/foreach}
        </p>
        <p>
            <label for="" class="search-f-label">周筛选：</label>
            <select name="search_filter[week]" style="width:230px;">
                {foreach $weekList as $k=>$v}
                <option value="{$k}" {if $k == $search_filter['week']}selected="selected"{/if}>{$v.start} - {$v.end}</option>
                {/foreach}
            </select>
        </p>
        <p><label for="" class="search-f-label"></label><button type="submit" class="btn btn-success btn-xs js_searchBtn">搜索</button></p>
    </form>
</div>

<section style="height:auto;line-height:auto;">
    <p>
        <span class="label label-info">专资办</span>
        <a href="{AnUrl("cinema/admin/cinema_daily_brief?{URLTracker::set("include_zzb_code", -1)}")}" {if $include_zzb_code == -1} class="label label-primary" {else} class="label label-default" {/if}>全部</a>
        <a href="{AnUrl("cinema/admin/cinema_daily_brief?{URLTracker::set("include_zzb_code", 1)}")}" {if $include_zzb_code == 1} class="label label-primary" {else} class="label label-default" {/if}>有专资办编码</a>
        <a href="{AnUrl("cinema/admin/cinema_daily_brief?{URLTracker::set("include_zzb_code", 0)}")}" {if $include_zzb_code == 0} class="label label-primary" {else} class="label label-default" {/if}>无专资办编码</a>
    </p>
    <p>
        <span class="label label-info">排序</span>
        <a href="{AnUrl("cinema/admin/cinema_daily_brief?{URLTracker::set("order_type", -1)}")}" {if $order_type == -1} class="label label-primary" {else} class="label label-default" {/if}>默认</a>
        <a href="{AnUrl("cinema/admin/cinema_daily_brief?{URLTracker::set("order_type", 1)}")}" {if $order_type == 1} class="label label-primary" {else} class="label label-default" {/if}>票房</a>
        <a href="{AnUrl("cinema/admin/cinema_daily_brief?{URLTracker::set("order_type", 2)}")}" {if $order_type == 2} class="label label-primary" {else} class="label label-default" {/if}>观影人次</a>
        <a href="{AnUrl("cinema/admin/cinema_daily_brief?{URLTracker::set("order_type", 3)}")}" {if $order_type == 3} class="label label-primary" {else} class="label label-default" {/if}>进货金额</a>
        <a href="{AnUrl("cinema/admin/cinema_daily_brief?{URLTracker::set("order_type", 4)}")}" {if $order_type == 4} class="label label-primary" {else} class="label label-default" {/if}>SPP</a>
    </p>
</section>

<section id="month_map" style="height: 600px;margin: 20px 0 0 0;"></section>
<p style="text-align: center;margin-bottom: 20px">近6周影院订单</p>

<!--start:列表-->
<table class="list-table">
    <thead><tr>
        <!-- {if $status == 1}
        <th style="width:20px;"><input type="checkbox" class="selectAll"></th>
        {/if} -->
        <th>序号</th>
        <th>store_id</th>
        <th>专资编码</th>
        <th style="min-width: 100px;">影院名称</th>
        <th style="min-width: 70px;">签约时间</th>
        <th style="min-width: 50px;">省市区</th>
        <th>票房/元</th>
        <th>观影人次</th>
        <th>进货金额</th>
        <th>SPP</th>
        <th>操作</th>
    </tr></thead>
    <tbody>
    {foreach $store_list as $k=>$v}
    <tr {if $k%2 == 1} class="bg-gray"{/if}>
    <!-- {if $status == 1}
      <td><input type="checkbox" class="listSelect"></td>
    {/if} -->
    <td>{$k+1}</td>
    <td>{$v.store_id}</td>
    <td>{$v.zzb_id}</td>
    <td data_id="{$v.store_id}">{$v.cinema_name}</td>
    <td>{time_format($v.add_time)}</td>
    <td>{$v.province}<br>{$v.city}<br>{$v.county}</td>
    <td>{$v.box_office}</td>
    <td>{$v.viewers}</td>
    <td>{$v.order_money}</td>
    <td>{if $v.spp != -1}
        {if $v.spp <= 0.3}
                  <span class="label label-danger">
                  {/if}
                  {if $v.spp <= 0.4 && $v.spp > 0.3}
                  <span class="label label-warning">
                  {/if}
                  {if $v.spp <= 0.6 && $v.spp > 0.4}
                  <span class="label label-success">
                  {/if}
                  {if $v.spp > 0.6}
                  <span class="label label-primary">
                  {/if}
                  {$v.spp}</span>
              {/if}
    </td>
    <td>
        <a href="{AnUrl("cinema/admin/cinema_manage/show?id={$v.store_id}")}" class="btn btn-success btn-xs"><i class="icon-trash icon-white"></i>查看详情</a>
    </td>
    </tr>
    {foreachelse}
    <tr><td class="txtleft" colspan="15">暂无数据</td></tr>
    {/foreach}
    </tbody>
</table>

<div class="float-bg" style="z-index: 19999; display: none"></div>
{include_core file="admin/lib/pager.html"}

<!--end:列表-->
{load_js file='zclip/jquery.zclip.min.js'}
{load_js file='zclip/ZeroClipboard.js'}
{load_js file='echarts/echarts.min.js'}
<script type="text/javascript">
    $(function () {
        var temp = '<div class="linkpop list_detail_pop" style="display: none;">\
                <div class="inner-linkpop" style="padding:8px;max-width:inherit;">\
                <span>\
                <i class="arrowpop"></i>\
                <b class="arrowpop2"></b>\
                </span>\
                <p class="options-list">\
                <table class="list-table">\
                <caption style="height:auto;line-height:auto;">影院名称</caption>\
                <thead>\
                <tr>\
                <th>院线</th>\
                <th>影投公司</th>\
                <th>最后进货时间</th>\
                <th>本月进货金额</th>\
                <th>影院专员</th>\
                <th>合伙人</th>\
                <th>影院负责人</th>\
                <th>累计进货金额</th>\
                </tr>\
                </thead>\
                <tbody>\
                <tr>\
                <td></td>\
                <td></td>\
                <td></td>\
                <td></td>\
                <td></td>\
                <td></td>\
                <td></td>\
                <td></td>\
                </tr>\
                </tbody>\
                </table>\
                </p>\
                </div>\
                </div>'
        $(document.body).append($(temp));

        var data_id = 0;
        var layerDetail = $('.list_detail_pop');
        var layerDetailContent = $('.list_detail_pop table tbody td');

        $(document.body).on('mouseover', function(e){
            var tar = e.target;
            while (true){
                if (tar.nodeName == 'TD' && $(tar).attr('data_id')) {
                    break;
                }
                if (tar.nodeName == "BODY"){
                    layerDetail.hide();
                    return;
                }
                tar = tar.parentNode;
            }

            var new_data_id = $(tar).attr('data_id');
            if (new_data_id){
                if(data_id == new_data_id){
                    return;
                }
            } else {
                layerDetail.hide();
            }

            data_id = new_data_id;

            if(!data_id){
                return;
            }

            $.ajax({
                        url : '{AnUrl("cinema/admin/cinema_brief/detail?id=")}' + data_id,
                        type : 'get',
                        dataType : 'json',
                        success : function(cinema_detail) {
                            if(cinema_detail.flag == 1){
                                layerDetailContent[0].innerHTML = cinema_detail.message.circuit;
                                layerDetailContent[1].innerHTML = cinema_detail.message.investment_company;
                                layerDetailContent[2].innerHTML = cinema_detail.message.last_order_time;
                                layerDetailContent[3].innerHTML = cinema_detail.message.new_month_cinema_order_money;
                                layerDetailContent[4].innerHTML = cinema_detail.message.cinema_assistant;
                                layerDetailContent[5].innerHTML = cinema_detail.message.agency;
                                layerDetailContent[6].innerHTML = cinema_detail.message.owner;
                                layerDetailContent[7].innerHTML = cinema_detail.message.all_order_money;

                                var position = $(tar).position();

                                layerDetail.css('top', position.top + 110);
                                layerDetail.css('left', position.left + 20);

                                layerDetail.show();
                            }
                        }
                    }
            );
        });

        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('month_map'));
        var option = {
            tooltip : {
                trigger: 'axis'
            },
            legend: {
                data:[]
            },
            toolbox: {
                feature: {
                    saveAsImage: {}
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis : {
                type : 'category',
                boundaryGap : false,
                data : []
            },
            yAxis : [
                {
                    type : 'value'
                }
            ],
            series : []
        };

        $.ajax({
            url : 'cinema/admin/cinema_daily_brief/chart?province_ids={$province_ids}',
            type : 'get',
            dataType : 'json',
            success : function(cinema_money) {
                if(cinema_money.flag == 1){
                    option.xAxis.data = cinema_money.message.six_weeks;
                    option.legend.data = cinema_money.message.line_name;
                    var money_list = cinema_money.message.money_list;
                    for(var i = 0; i < money_list.length; i++){
                        option.series.push({
                            name:cinema_money.message.line_name[i],
                            type:'line',
                            stack: '总计',
                            data:money_list[i]
                        });
                    }

                    setTimeout(function(){
                        myChart.setOption(option);
                    }, 1000);
                }
            }
        });
    });
</script>
{include_core file="admin/lib/footer.html"}